/*
 * Copyright 2025 The JA-SIG Collaborative. All rights reserved.
 * distributed with this file and available online at
 */
package com.lap.auth.domain.login;

import com.lap.framework.common.ddd.AggregateRoot;
import lombok.Getter;

/**
 * 登录日志领域。
 *
 * @author Shuisheng Lao(劳水生)
 * @version 0.0.1
 */
@Getter
public class LoginLog extends AggregateRoot {

  private final Integer id;
  private Integer userId;
  private String fullName;
  private final String userName;
  private String browser;
  private String operatingSystem;
  private String loginIp;
  private String loginAddress;
  private final Integer success;
  private final String remark;
  private final Long times;

  public LoginLog(
      Integer id,
      Integer userId,
      String userName,
      String fullName,
      String browser,
      String operatingSystem,
      String loginIp,
      String loginAddress,
      Integer success,
      String remark,
      Long times) {
    this.id = id;
    this.userId = userId;
    this.userName = userName;
    this.fullName = fullName;
    this.browser = browser;
    this.operatingSystem = operatingSystem;
    this.loginIp = loginIp;
    this.loginAddress = loginAddress;
    this.success = success;
    this.remark = remark;
    this.times = times;
  }

  public void changeUserInfo(Integer userId, String fullName) {
    this.userId = userId;
    this.fullName = fullName;
  }

  public void changeDevice(
      String browser, String operatingSystem, String loginIp, String loginAddress) {
    this.browser = browser;
    this.operatingSystem = operatingSystem;
    this.loginIp = loginIp;
    this.loginAddress = loginAddress;
  }

  public boolean isNew() {
    return (id == null);
  }
}
